package com.wc.alorithm_blue_bridge._贪心.Q1228;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

/**
 * @Author congege
 * @Description 小明的衣服
 * https://www.lanqiao.cn/problems/1228/learning/?page=1&first_category_id=1&sort=students_count&second_category_id=8
 * @Date Created in 2023/10/30-20:13
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();
        int n = sc.nextInt();
        int[] array = new int[n];
        long sum = 0;
        long ans = 0;
        while (n-- > 0) {
            array[n] = sc.nextInt();
            sum += array[n];
        }
        Arrays.sort(array);
        ans += sum;
        for (int i = array.length - 1; i >= 2; i--) {
            sum -= array[i];
            ans += sum;
        }
        System.out.println(ans);
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
